package com.jkl.queryserver.Provider.DAO.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.jkl.pojo.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface MessageMapper extends BaseMapper<Message> {
    default List<Message> selectUnreceivedMessages(@Param("email") String email, @Param("lastTime") Long lastTime){
        return selectList(new QueryWrapper<Message>()
                .eq("receiver",email)
                .gt("createTime",lastTime));
    }
    default List<Message> selectMessages(String email){
        return selectList(new QueryWrapper<Message>()
                .eq("sender",email).or().eq("receiver",email));
    }
}
